package com.guqj.jvm;

import java.util.List;

import org.junit.Test;

public class StackTest {

	static {
		int i = 1;
		System.out.println(i);
		
	}
	private int count = 0;

	/*
	 * public void recursion() { count++; recursion(); }
	 */

	public void recursion(long a, long b, long c, long d) {
		long e = 0, f = 0, g = 0;
		count++;
		recursion(a, b, c, d);
	}

	@Test
	public void testStack() {
		try {
			recursion(1L, 2L, 3L, 4L);
		} catch (Throwable e) {
			System.out.println("deep of stack is " + count);
			e.printStackTrace();
		}
	}

	public static void test1() {
		{
			byte[] b = new byte[10 * 1024 * 1024];
		}
		System.gc();
		System.out.println("first explict gc over");
	}

	public static void test2() {
		{
			byte[] b = new byte[10 * 1024 * 1024];
			b = null;
		}
		System.gc();
		System.out.println("first explict gc over");
	}

	public static void test3() {
		{
			byte[] b = new byte[10 * 1024 * 1024];
		}
		
		int a = 0;
		System.gc();
		System.out.println("first explict gc over");
	}
	
	public static void main(String[] args) {
		Integer a = 1;
		Integer b = 2;
		Integer c = 3;
		Integer d = 3;
		Integer e = 321;
		Integer f = 321;
		Long g = 3L;
		Long h = 123L;
		Long j = 123L;
		System.out.println(c == d); // true
		System.out.println(e == f); // false
		System.out.println(c == (a + b)); // true
		System.out.println(c.equals(a + b)); // true
		System.out.println(g  == (a + b)); // true
		System.out.println(g.equals(a + b)); // false
		System.out.println(h == j); // false
	}
}
